home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / SpriteEngine / SE Gravity / SpriteHanders.c < prev    next >
C/C++ Source or Header  |  1995-03-11  |  1KB  |  62 lines

  1. #include "SpriteTools.h"
  2.  
  3. // SpriteTools.h includes SpriteHandlers.h
  4.  
  5.  
  6. /*** Custom handlers - application dependent ***
  7.  
  8. Edit this as necessary. It should always include the following three routines:
  9.  
  10. MoveSprite: move the sprite
  11.  
  12. HitSprite: handle collisions between two sprites
  13.  
  14. InitSprites: Load all faces and create initial sprites
  15.  
  16. ***/
  17.  
  18.  
  19.  
  20. GrafPtr    firstFace, secondFace, thirdFace;
  21.  
  22.  
  23. void MoveSprite(SpritePtr theSprite)
  24. {
  25.     theSprite->speed.v++;
  26.     theSprite->position.h += theSprite->speed.h;
  27.     theSprite->position.v += theSprite->speed.v;
  28.     KeepOnScreen(theSprite);
  29.  
  30. } /*MoveSprite*/
  31.  
  32. void HitSprite(SpritePtr theSprite, SpritePtr anotherSprite)
  33. {
  34. } /*HitSprite*/
  35.  
  36.  
  37. void InitSprites()
  38. {
  39.     SpritePtr    theSprite;
  40.  
  41. /*Load all pictures*/
  42.     firstFace = LoadFaceFromCicn(128);            /*cicn resource #128.*/
  43.     secondFace = LoadFaceFromCicn(129);            /*cicn resource #129.*/
  44.     thirdFace = LoadFaceFromCicn(130);            /*cicn resource #130.*/
  45.  
  46. /*Create sprites*/
  47.     theSprite = NewSprite();
  48.     theSprite->face = firstFace;
  49.     SetPt(&theSprite->position, 100, 100);
  50.     SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
  51.  
  52.     theSprite = NewSprite();
  53.     theSprite->face = secondFace;
  54.     SetPt(&theSprite->position, 50, 50);
  55.     SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
  56.  
  57.     theSprite = NewSprite();
  58.     theSprite->face = thirdFace;
  59.     SetPt(&theSprite->position, 150, 150);
  60.     SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
  61. } /*InitSprites*/
  62.